// Package protocol defines the Celery protocol interface for GoCelery
package protocol

import (
	"time"

	"gitee.com/yuebanlaosiji/gocelery/pkg/types"
)

// Task represents a task to be executed
type Task struct {
	ID        string
	Name      string
	Args      []interface{}
	Kwargs    map[string]interface{}
	Retries   int
	ETA       *time.Time
	ExpiresAt *time.Time
}

// TaskResult represents the result of a task execution
type TaskResult struct {
	TaskID    string
	Status    string
	Result    interface{}
	Traceback string
	Error     string
}

// Protocol is the interface for the Celery wire protocol
type Protocol interface {
	// Create a task message
	CreateTaskMessage(task types.Task) ([]byte, error)

	// Parse a task message
	ParseTaskMessage(data []byte) (types.Task, error)

	// Create a result message
	CreateResultMessage(result types.TaskResult) ([]byte, error)

	// Parse a result message
	ParseResultMessage(data []byte) (types.TaskResult, error)
}
